<template>
    <view class="nova-column" style="padding: 0 34rpx;">
        <view class="nova-row-center info">
            <image style="width: 120rpx; height: 120rpx; margin: 34rpx; border-radius: 6rpx;" :src="aunty.photo"></image>
            <view class="nova-column">
                <text class="title">{{ aunty.name }}</text>
                <text class="line1">{{ getLine1() }}</text>
            </view>
        </view>
        <view class="nova-column">
            <view class="nova-row-center">
                <text class="label">综合评价</text>
                <uni-rate class="nova-row-center rate" activeColor="#ff6702" max="5" size="18" :value="form.comprehensive_star" @change="star1"></uni-rate>
            </view>
            <view class="nova-row-center">
                <text class="label">服务态度</text>
                <uni-rate class="nova-row-center rate" activeColor="#ff6702" max="5" size="18" :value="form.attitude_star" @change="star2"></uni-rate>
            </view>
            <view class="nova-row-center">
                <text class="label">服务能力</text>
                <uni-rate class="nova-row-center rate" activeColor="#ff6702" max="5" size="18" :value="form.ability_star" @change="star3"></uni-rate>
            </view>
            <view class="nova-row-center">
                <text class="label">个人修养</text>
                <uni-rate class="nova-row-center rate" activeColor="#ff6702" max="5" size="18" :value="form.culture_star" @change="star4"></uni-rate>
            </view>
        </view>
        <textarea class="ta" v-model="form.evaluate_content" placeholder="您对阿姨的服务是否满意，和大家分享一下吧！"></textarea>
        <view class="btn-primary btn" @click="doSubmit">提交</view>
    </view>
</template>

<script>
import uniRate from '@/components/uni-rate/uni-rate.vue';
export default {
    components: { uniRate },
    data() {
        return {
            aunty: {},
            form: {
                resume_id: '',
                comprehensive_star: '',
                evaluate_content: '',
                attitude_star: '',
                ability_star: '',
                culture_star: ''
            }
        };
    },
    methods: {
        getLine1() {
            let arr = [];
            let job = this.aunty;
            if (job) {
                if (job.sex) {
                    arr.push(job.sex);
                }
                if (job.birthday) {
                    arr.push(job.birthday);
                }
                if (job.zodiac) {
                    arr.push(job.zodiac);
                }
                if (job.area) {
                    arr.push(job.area);
                }
                if (job.workYear) {
                    arr.push(job.workYear + '年工作经验');
                }
            }
            return arr.join(' | ');
        },
        star1(e) {
            console.log(e);
            this.form.comprehensive_star = e.value;
        },
        star2(e) {
            this.form.attitude_star = e.value;
        },
        star3(e) {
            this.form.ability_star = e.value;
        },
        star4(e) {
            this.form.culture_star = e.value;
        },
        async doSubmit(e) {
            let err = '';
            if (!this.form.comprehensive_star) {
                err = '请对综合评价打分';
            } else if (!this.form.attitude_star) {
                err = '请对服务态度打分';
            } else if (!this.form.ability_star) {
                err = '请对服务能力打分';
            } else if (!this.form.culture_star) {
                err = '请对个人修养打分';
            } else if (!this.form.evaluate_content) {
                err = '请输入评价';
            }
            if (err) {
                this.$toast(err);
                return;
            }
            this.form.resume_id = this.aunty.resume_id
            this.form.type = this.aunty.type;
            this.form.aunt_status = this.aunty.aunt_status;
            let res = await this.$request.post({
                url: '/publish/evaluateInsert',
                data: this.form
            });
            this.$toast('评价成功');
            setTimeout(function() {
                uni.navigateBack({});
            }, 500);
        }
    },
    onLoad() {
        this.aunty = uni.getStorageSync('aunty');
    }
};
</script>

<style lang="scss">
.info {
    color: #000;
    .title {
        font-size: 36rpx;
    }
    .line1 {
        font-size: 24rpx;
        color: #666666;
    }
}
.label {
    font-size: 30rpx;
    padding-right: 32rpx;
    line-height: 64rpx;
}
.rate {
    margin-top: 10rpx;
}
.ta {
    margin-top: 30rpx;
    width: 100%;
    height: 266rpx;
    border: 1rpx solid rgba(238, 238, 238, 1);
    border-radius: 12rpx;
    padding: 28rpx;
    box-sizing: border-box;
}
.btn {
    line-height: 80rpx;
    text-align: center;
    margin: 60rpx 0;
}
</style>
